package com.smt.ejb3.tutoria.entitybean.one2one.pk;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;

@Entity
public class Customer implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private int id;
	private String name;
	private CustomerNo custNo;
	
	@Id
	@Column(name="CUST_ID")
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToOne
	@PrimaryKeyJoinColumn(name="CUST_ID", referencedColumnName="CUSTNO_ID")
	public CustomerNo getCustNo() {
		return custNo;
	}
	public void setCustNo(CustomerNo custNo) {
		this.custNo = custNo;
	}
	
	public String toString(){
		return getName() + " " + getCustNo().getSn();
	}
}
